by Bouke (1 Submission)
Category: Files/File Controls/Input/Output
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Sun 26th December 1999
Date Added: Mon 8th February 2021
Rating: (1 Votes)
Create directory more than one level deep, such as C:\Windows\MyApp\Files. Returns True if succeeded or False if failed creating directory.
On Error Resume Next
Dim bytMax As Byte
Dim bytNdx As Byte
Dim strDirLevel As String
If Right(strDir, 1) <> "\" Then
strDir = strDir & "\"
End If
bytMax = Len(strDir)
For bytNdx = 4 To bytMax
If (Mid(strDir, bytNdx, 1) = "\") Then
strDirLevel = Left(strDir, bytNdx - 1)
If Dir(strDirLevel, vbDirectory) = "" Then
MkDir strDirLevel
End If
End If
Next
If Dir(strDir, vbDirectory) <> "" Then
CreateDir = True ' Succeeded creating directory
Else
CreateDir = False ' Failed creating directory
End If
End Function
No comments have been posted about Create directory more than one level deep, such as C:\Windows\MyApp\Files. Returns True if succeede. Why not be the first to post a comment about Create directory more than one level deep, such as C:\Windows\MyApp\Files. Returns True if succeede.